/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2023-11-01
 * Time: 20:45
 */
public class Test {
    /*//递归求斐波那契数列的第 N 项
    public static int fib(int n) {
        if(n == 1 || n == 2) {
            return 1;
        }
        int ret = fib(n-1) + fib(n-2);
        return ret;
    }
    public static void main(String[] args) {
        int ret = fib(5);
        System.out.println(ret);
    }*/
    //写一个递归方法，输入一个非负整数，返回组成它的数字之和
  /*  public static int sumEvery(int n) {
        if(n <10) {
            return n;
        }
        int sum = n%10 + sumEvery(n/10);
        return sum;
    }
    public static void main(String[] args) {
            int sum = sumEvery(1234);
        System.out.println(sum);
    }*/
    /*//按顺序打印一个数字的每一位(例如 1234 打印出 1 2 3 4)（递归）
    public static void print(int n) {
        if(n!=0) {
            print(n/10);
            System.out.print(n%10+" ");
        }
    }
    public static void main(String[] args) {
        print(1234);
    }*/
/*    //递归求 1 + 2 + 3 + ... + 10
    public  static  int sumEvery(int n) {
        if(n == 1){
            return 1;
        }
        int sum = n+sumEvery(n-1);
        return sum;
    }

    public static void main(String[] args) {
        System.out.println(sumEvery(10));
    }*/
    /*//递归求 N 的阶乘
    //5!  5*4!
    //4!  4*3!
    //.....
    public static int fun(int n) {
        if(n == 1) {
            return 1;
        }
        int tmp = n * fun(n-1);
        return tmp;
    }
    public static void main(String[] args) {
        System.out.println(fun(5));
    }*/
}
